#ifndef HITTABLE_LIST_H
#define HITTABLE_LIST_H

#include "hittable.h"
#include <memory>
#include <vector>

using std::make_shared;
using std::shared_ptr;

class HittableList : public Hittable {
  public:
    std::vector<shared_ptr<Hittable>> objects;

    HittableList() {}
    HittableList(shared_ptr<Hittable> object) { add(object); }

    void clear() { objects.clear(); }

    void add(shared_ptr<Hittable> object) {
        objects.push_back(object);
        bbox = AABB(bbox, object->bounding_box());
    }

    double pdf_value(const Point3& origin, const Vec3& direction) const override;
    Vec3 random(const Point3& origin) const override;

    bool hit(const Ray& r, Interval ray_t, HitRecord& rec) const;

    AABB bounding_box() const override { return bbox; }

private:
    AABB bbox;
};

#endif